package com.diankangwo.dao.impl;

import com.diankangwo.dao.PhoneAndCodeDAO;
import com.diankangwo.domain.PhoneAndCode;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class PhoneAndCodeDAOImpl extends BaseDaoImpl<PhoneAndCode> implements PhoneAndCodeDAO {


    /**
     * 倒序获取指定条数信息
     */
    public List<PhoneAndCode> findOrderBy(int count) {
//        try {
//            String sql = "from PhoneAndCode p order by p.time desc";
//            return this.getCurrentSession().createQuery(sql).setFirstResult(0).setMaxResults(count).list();
//        } catch (Exception e) {
//            return null;
//        }
        return null;
    }

    @Override
    public boolean findByCode(String tel, String code) {
        String hql = "from PhoneAndCode p where p.phone = ? and p.code =?";
        List<PhoneAndCode> pList = findByQuery(hql, tel, code);
        if (pList.size() > 0) {
            return true;
        } else {
            return false;
        }
    }

}
